﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace VASJ.Service.Library.Manager
{
    public class ApplicationLinkManager : BaseManager
    {
        /// <summary>
        /// Init
        /// </summary>
        /// <param name="_ApplicationName"></param>
        public ApplicationLinkManager(string _ApplicationName)
            : base(_ApplicationName)
        {

        }

        /// <summary>
        /// Get link by application
        /// </summary>
        /// <returns></returns>
        public string GetLinkByApplication()
        {
            try
            {
                var als = from al in this.mdb.AHSApplicationLinks
                          where al.ApplicationName.ToLower() == this.ApplicationName.ToLower()
                          select al.ApplicationLink;
                return (als != null && als.Count() > 0) ? als.FirstOrDefault() : string.Empty;
            }
            catch (Exception ex)
            {
                Logger.Log.ErrorFormat("[" + this.ApplicationName + "] ApplicationLinkManager.GetLinkByApplication error ", ex);

                return string.Empty;
            }
        }
    }
}